<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>51.flat和flatMap</title>
</head>
<body>
<script>
  let arr = [1,2,3,[5,[6,7]]]
  //可以传递一个深度参数，代表展开的次数，默认是1
  console.log(arr.flat())//[1,2,3,5,[6,7]]
  console.log(arr.flat(2))//[1,2,3,5,6,7]

  let arr2 = [1,2,3,5,[6,7]]
  console.log(arr2.flatMap(x=>x * 2))
  console.log(arr2.map(x=>x * 2))


</script>
</body>
</html>